package com.wing.sys.dao;

import java.util.List;

import org.springframework.jdbc.core.namedparam.BeanPropertySqlParameterSource;
import org.springframework.stereotype.Repository;

import com.wing.common.CommonSpringJDBC;
import com.wing.sys.domain.RoleModule;

@Repository
public class RoleModuleDao extends CommonSpringJDBC<RoleModule, String> {

	public List findRoleModule(RoleModule rm) {
		String sql = "select rm.* from sys_role_module rm where rm.roleid=:roleid and rm.moduleid=:moduleid ";
		return super.getSimpleJdbcTemplate().queryForList(sql, new BeanPropertySqlParameterSource(rm));
	}

	public void deleteRoleModule(String moduleId, String roleId) {
		String sql = "delete from sys_role_module  where roleid='"+roleId+"' and moduleid='"+moduleId+"'";
		super.getSimpleJdbcTemplate().update(sql);
	}

	public void deleteRoleModuleByRoleId(String roleId) {
		String sql = "delete from sys_role_module  where roleid='"+roleId+"'";
		super.getSimpleJdbcTemplate().update(sql);
	}

	public void deleteRoleModuleByModuleId(String moduleId) {
		String sql = "delete from sys_role_module  where moduleid='"+moduleId+"'";
		super.getSimpleJdbcTemplate().update(sql);
	}
	
}
